package com.xyj.action.menu;

import com.opensymphony.xwork2.ModelDriven;
import com.xyj.action.base.BaseAction;
import com.xyj.domain.TMenu;
import com.xyj.pageModel.Menu;
import com.xyj.service.MenuServiceI;
import com.xyj.util.LoggerUtil;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by 徐宇健 on 2015/2/12 0012.
 */
@Namespace("/menu")
@Action("menuAction")
public class MenuAction  extends BaseAction implements ModelDriven<Menu>{

    private  Menu menu = new Menu();
    private MenuServiceI menuService;

    public MenuServiceI getMenuService() {
        return menuService;
    }

    @Autowired
    public void setMenuService(MenuServiceI menuService) {
        this.menuService = menuService;
    }

    @Override
    public Menu getModel() {
        return menu;
    }

    public void  showMenu(){
        LoggerUtil.getLogger().info("action>>>>>showMenu>>>>>>>>begin");
//        List<Menu> menus =  menuService.getMenuTree(menu.getId());
        List<Menu> menus = menuService.getAllMenuTrees();
        super.writeJson(menus);
        LoggerUtil.getLogger().info("action>>>>>showMenu>>>>>>>>end");


    }
}
